home *** CD-ROM | disk | FTP | other *** search
/ .net 1998 August / netCD48.iso / mac / net / SoftCen / Utils / Mac / Apple Error Codes '98 / Apple Error Codes '98.rsrc / TEXT_2000_uText.txt < prev    next >
Text File  |  1997-12-02  |  21KB  |  458 lines

  1.  
  2. Power Macintosh: Type 11 & No FPU Errors Technote (7/96)
  3.  
  4. Article Created: 10 November 1995
  5. Article Reviewed/Updated: 02 July 1996
  6.  
  7. TOPIC 
  8. ---------------------------------------------------------
  9. This Technote explains some of the causes of "Type 11" 
  10. and "No FPU Installed" errors, along with debugging 
  11. hints to help you find and fix them. It also focuses 
  12. on what you as a programmer can do to prevent such 
  13. errors.
  14.  
  15. DISCUSSION 
  16. ----------------------------------------------------
  17. Both Type 11 and No FPU Installed errors occur on 
  18. Power Macintosh computers, depending on various 
  19. factors. Both error messages are the result of 
  20. programming errors. The No FPU Installed error usually 
  21. means that your program is executing data rather than 
  22. instructions. The Type 11 error is any error (such as 
  23. a bus error) in native code.
  24. NOTE: In this Technote, I will occasionally mention 
  25. third-party products by name. If a third-party product 
  26. is mentioned by name, it's meant to be a possible 
  27. solution for you to investigate, not a recommendation. 
  28. DTS doesn't evaluate third-party tools, nor maintain 
  29. complete lists of possible third-party solutions. You 
  30. should consult catalogs of development tools such as:
  31. * Macintosh Development Tools & Languages
  32. * the Redgate Macintosh Registry
  33. * the ubiquitous Internet
  34. * the APDA catalog and
  35. * reviews in technical magazines to find a product 
  36. that fits your needs.
  37. There are many Web sites on the Internet ‚Äπ‚Äπ for 
  38. example, Apple's Third-Party Development Products 
  39. Database at  lists many Macintosh development tools. 
  40. Perhaps you may find an appropriate tool to meet your 
  41. development needs in this way.
  42.  
  43. About "No FPU Installed" Errors
  44. ===============================
  45. On a Power Macintosh computer, the error message No 
  46. FPU Installed usually means your code has jumped to a 
  47. non-code area and is executing garbage. Somewhere in 
  48. that data (which is being interpreted as instructions) 
  49. is an instruction whose op code begins with the hex 
  50. value F. No FPU Installed is equivalent to a Type 10 
  51. Error ‚Äπ‚Äπ i.e., your program has attempted to execute 
  52. an unknown instruction op code starting with the hex 
  53. value F.
  54. On a Power Macintosh, No FPU Installed means that some 
  55. program has jumped to an area of data and has tried to 
  56. execute any data word starting with the hex value F. 
  57. The PowerPC chip has floating point support built in, 
  58. but that floating-point support is different from the 
  59. Motorola 680x0 family floating- point support. The 
  60. Motorola 680x0 family uses an external floating-point 
  61. unit. (There are also external memory management units 
  62. (MMUs) and other specialized coprocessors.) Motorola 
  63. 680x0 CPUs use instructions starting with hex value F 
  64. as instructions for these coprocessors.
  65.  
  66. 680x0 Microprocessor Instructions
  67. ---------------------------------
  68. All Motorola 680x0 microprocessors have instructions 
  69. consisting of at least one word (the operation word); 
  70. some instructions can have up to eleven words (see the 
  71. Motorola MC68020 32-bit Microprocessor User's Manual, 
  72. Third edition, page 3-1.) The operation word 
  73. determines what kind of instruction is to be executed. 
  74. For example, the instruction
  75. MOVE.B D1, D2
  76. translates to the hexadecimal value
  77. 1401
  78. This instruction starts with the hex value 1. The 
  79. instruction
  80. FMOVE.X FP3,-(A7)
  81. translates to
  82. F227 6980
  83. This instruction starts with the hex value F.
  84.  
  85. F-line Instructions
  86. -------------------
  87. The Motorola 680x0 architecture was originally 
  88. designed to support a floating- point coprocessor 
  89. chip. This chip, the Floating Point Unit (FPU), 
  90. communicates with the CPU via a special set of 
  91. instructions called F-line instructions. These 
  92. instructions always start with an operation word 
  93. beginning with the hex value F.
  94. A program can be compiled to take advantage of the 
  95. hardware assistance the FPU provides, and thus yield 
  96. faster floating-point calculations than would be 
  97. available with SANE (the Standard Apple Numerics 
  98. Package). Such programs would have instructions in the 
  99. program which start with the hex value F. A program 
  100. only using SANE would never have an instruction 
  101. starting with the hex value F.
  102. NOTE: Some Macintosh models, such as the Macintosh SE/
  103. 30, the Macintosh IIci, and the Macintosh IIfx, 
  104. shipped with an FPU coprocessor installed. Other 
  105. 680x0-based Macintosh computers, such as the Macintosh 
  106. IIsi and the Macintosh Color Classic, had an optional 
  107. FPU coprocessor. For these machines, it was possible 
  108. to purchase an optional card with an FPU coprocessor.
  109.  
  110. 68040 & 68040LC Microprocessors
  111. -------------------------------
  112. With the introduction of the 68040 and 68040LC chips, 
  113. things got a bit more complicated. The 68040 
  114. microprocessor has most of the 68882 FPU included on 
  115. the chip. Not everything in the 68881/68882 FPU is in 
  116. the 68040 chip, however ‚Äπ‚Äπ just the routines that 
  117. Motorola determined were most frequently used. The 
  118. rest of the FPU routines are automatically emulated by 
  119. software. Because the FPU is "built-in," as it were, 
  120. the 68040 chip handles instructions that start with an 
  121. operation word beginning with the hex value F by 
  122. itself. There is no way to add a coprocessor to a 
  123. 68040 chip; the instructions are never brought out of 
  124. the chip itself.
  125. The 68040LC is a cost-reduced version of the 68040 
  126. chip. Savings came about by removing the FPU portion 
  127. of the chip. Not only does a 68040LC chip have no FPU, 
  128. there is no way to add one.
  129.  
  130. The Power Macintosh
  131. -------------------
  132. Power Macintosh computers emulate a Motorola 68040LC, 
  133. i.e., a machine without FPU support. When you get a 
  134. bomb with the message No FPU installed, it means some 
  135. instruction has been executed with an operation word 
  136. starting with the hex value F, and that your program 
  137. is running on a machine without a FPU. This machine 
  138. could be one of the following:
  139. * a Macintosh with a 68020 or 68030 microprocessor and 
  140. no FPU coprocessor
  141. * a Macintosh with a 68040LC microprocessor (which can 
  142. never have a FPU)
  143. * a Macintosh with a PowerPC chip running 68K code in 
  144. emulation (since the 68K emulator emulates a 68040LC 
  145. microprocessor).
  146. Power Macintosh computers contain very fast floating-
  147. point support as part of the CPU. This floating-point 
  148. support is different from the floating-point support 
  149. provided by the Motorola 680x0 microprocessors. Inside 
  150. Macintosh:PowerPC Numerics, describes Power Macintosh 
  151. floating-point support.
  152.  
  153. Defining a Type 11 Error
  154. ========================
  155. A Type 11 error means an illegal interrupt vector on a 
  156. 680x0 machine. On a Power Macintosh, a Type 11 error 
  157. is any exception in native code not handled by one of 
  158. the installed exception handlers. On a Power 
  159. Macintosh, a Type 11 error can be almost any error 
  160. that occurred in native code. Type 11 errors may 
  161. include:
  162. * an address error
  163. * a bus error
  164. * an illegal instruction error that occurred in native 
  165. code.
  166. The exception handlers installed for native code don't 
  167. correctly handle the particular condition which was 
  168. raised, and the error is returned back to the System 
  169. Error manager via the Mixed Mode manager. The System 
  170. Error manager maps all such exceptions to the system 
  171. error Type 11 Error.
  172. If you install Macsbug 6.5.2 or later, some Type 11 
  173. errors may be reported as a PowerPC unmapped memory 
  174. exception. This is equivalent to a bus error, i.e., an 
  175. error indicating your program is accessing memory that 
  176. doesn't exist.
  177. The Modern Memory Manager was designed to be less 
  178. forgiving than the classic (68K) Memory Manager. 
  179. Disposing of something twice, disposing of memory that 
  180. was never allocated, and other memory handling 
  181. problems will often generate a Type 11 error, while on 
  182. a 68K machine the problem may go unnoticed.
  183.  
  184. Programming Mistakes Causing Type 11 Errors
  185. ===========================================
  186. The following sections give you examples of 
  187. programming mistakes that may cause Type 11 errors.
  188.  
  189. Example #1: Writing Past the End of an Array
  190. --------------------------------------------
  191. Writing past the end of an array can be a subtle and 
  192. difficult-to-find bug. Example #1 shows you why.
  193. ;=======================================================
  194. ;Begin C Code
  195. ;
  196. void IAmGoingToCrash(void)
  197. {
  198. Str27   badArray;
  199. BlockMoveData("\pThis string is too long for this array", 
  200. badArray, 39);
  201. }
  202. ;
  203. ;End C Code
  204. ;=======================================================
  205.  
  206. NOTE: I've made the bug very obvious; it may not be 
  207. quite so obvious, however, in your code. In this 
  208. example, I've put a string of 39 characters into an 
  209. array defined to hold 27 characters. This overwrites 
  210. the stack, which contains such useful things as your 
  211. return address. On a 68K Mac, this causes a bus error. 
  212. On a PowerPC Mac in 68K emulation, this causes a bus 
  213. error. On a Power Macintosh in native code, this 
  214. causes a Type 11 error.
  215.  
  216. Example #2: Using a Poorly Initialized Pointer or Handle
  217. --------------------------------------------------------
  218. If your program tries to use an uninitialized or badly 
  219. initialized pointer, it can generate a Type 11 error. 
  220. Here is what happens in Example #2:
  221. ;=======================================================
  222. ;Begin C Code
  223. ;
  224. Ptr badPointer = (Ptr)-2;
  225. *badPointer = 0;
  226. ;
  227. ;End C Code
  228. ;=======================================================
  229.  
  230. NOTE: I've made the bug very obvious; it may not be quite so 
  231. obvious, however, in your code. In this example, I've created a 
  232. pointer to non-existent memory (-2 isn't a valid address) and then 
  233. tried to access the memory to which the pointer refers. On a 68K Mac, 
  234. this causes a bus error. On a PowerPC Mac in 68K emulation, this 
  235. also causes a bus error. On a Power Macintosh in native code, this 
  236. causes a Type 11 error.
  237.  
  238. Other Situations Causing Type 11 Errors
  239. =======================================
  240. The following sections document some of the known bugs in 
  241. various products that may cause Type 11 errors.
  242.  
  243. Color Picker vs Third-Party SCSI Drivers
  244. ----------------------------------------
  245. One reproducible problem stems from a known bug in several third-
  246. party SCSI hard disk drivers. The bug causes the Color Picker to crash 
  247. when trying to resolve a boot volume alias it makes at startup time. 
  248. This problem exists in any system when Color Picker 2.0 or 2.0.1 is 
  249. installed and the boot volume is not a removable drive. The 
  250. fundamental cause of the problem is that the SCSI driver incorrectly 
  251. marks the boot drive as a removable drive during the boot process 
  252. and changes it to be properly marked as a fixed device after startup. 
  253. To find its code, the Color Picker resolves the boot volume alias it 
  254. made during startup. Since the alias passed to the Alias Manager is 
  255. for a removable drive, the Alias Manager can't resolve the alias 
  256. (since the device is now marked as fixed.) The Color Picker design 
  257. did not anticipate the boot volume not being found. This results in a 
  258. Type 11 error. The fix is to upgrade your SCSI driver to a later 
  259. version.
  260.  
  261. Calling a Routine That May Move Memory at Interrupt Time
  262. --------------------------------------------------------
  263. The Apple Media Kit, release 1.2, had a problem that could cause 
  264. random errors. During a VBL task, AMK was calling SetCCursor. 
  265. SetCCursor can possibly move memory. Moving memory during 
  266. interrupt time is a very bad idea. The Memory Manager may be in an 
  267. unstable state, such as compacting memory, when an interrupt 
  268. routine gets called. This can cause a Type 11 error in native code.
  269. A replacement cursor.c file has been provided in the Apple Media 
  270. Tool/Programming Environment Runtime folder, and we do have a 
  271. replacement Runtime Maker:Codes:Program file for Apple Media 
  272. Tool. If you are currently developing titles, replacing these files and 
  273. rebuilding your projects will remove the bug.
  274.  
  275. Not Enough Heap Space
  276. ---------------------
  277. There are some situations where having small amounts of memory 
  278. available in the system heap may lead to a Type 11 error. As an 
  279. example, if the shared library manager can't load a shared library, 
  280. you may get a Type 11 error. This can happen when QuickTime tries 
  281. to load a decompressor for certain kinds of images.
  282.  
  283. Writing Past the End of an Array
  284. --------------------------------
  285. In OpenTransport 1.0.5 or earlier, there was a bug in the TCP/IP 
  286. control panel code that could corrupt memory if there were more 
  287. than 256 zones and a MacIP server was found in a zone past the 
  288. 256th zone. Under these conditions, the control panel code wrote 
  289. past the end of one of its buffers. This bug would manifest itself if the 
  290. user opened the select zone dialog and the TCP/IP control panel was 
  291. left open long enough for the NBP lookup calls for zones past the 
  292. 256th zone to complete. This is corrected in OpenTransport 1.0.6 and 
  293. later, but is given here as an example of a Type 11 error.
  294.  
  295. Insufficient Stack Space
  296. ------------------------
  297. Heavy use of local variables or recursion may cause your program to 
  298. run out of stack space. When this happens, you may have crashes 
  299. that are difficult to track down. Increasing your program's stack is 
  300. one solution. Whenever you are using a large number of local 
  301. variables or recursive routines, you should increase your program's 
  302. stack (using the procedure listed in Inside Macintosh: Memory on 
  303. page 1-40).
  304. As an extreme example, a faceless background application 
  305. (documented in Technical Note PS 2) has only a 2K stack by default. 
  306. A 68K application has 24K of stack on most modern machines (8K if 
  307. no Color QuickDraw is installed, 32K if A/UX is installed.) You can 
  308. use the low memory accessor function LMGetDfltStack to find your 
  309. current stack size. Native QuickDraw has several changes in 
  310. algorithms that have increased the size of some structures. PowerPC 
  311. alignment issues may cause the size of data structures to increase. 
  312. Check your compiler documentation for further details.
  313. To help detect collisions between the stack and the heap, a √ístack 
  314. sniffer√ì VBL task is installed that compares the current ends of the 
  315. stack and heap and generates a system error 28 in case of a collision. 
  316. Unfortunately, the Thread Manager is forced to disable the stack 
  317. sniffer whenever it is installed. (This is because threads can have a 
  318. stack in places where the stack sniffer doesn't expect them; if the 
  319. stack sniffer is enabled, it would generate a system error 28.) This 
  320. means you don't have the same level of protection as you did under 
  321. older system software versions without the Thread Manager 
  322. installed.
  323.  
  324. Too Much Recursion in QuickDraw
  325. -------------------------------
  326. Native QuickDraw before version 2.4.1 used a recursive routine to 
  327. handle regions. This recursive code could cause your stack to run 
  328. into the heap when handling certain region shapes. Version 2.4.1 of 
  329. QuickDraw changed to a non-recursive routine which eliminates 
  330. this error. (You can detect the version of QuickDraw using the 
  331. Gestalt selector √îqd √îwhich returns a version.) In general, recursion 
  332. on PowerMacs is dangerous unless you have substantial stack space 
  333. available; PowerPC stack frames are very large, and putting many of 
  334. them on the stack may quickly exhaust available stack.
  335.  
  336. Interrupts Not Handled by Device Drivers
  337. ----------------------------------------
  338. Some Type 11 errors may legitimately be illegal interrupt vector 
  339. errors, rather than simply unhandled exceptions in native code. If a 
  340. device driver for a NuBus or PCI card does not install an interrupt 
  341. service routine, but the card raises an interrupt, you will receive a 
  342. Type 11 error. This will happen whether you are running in 68K 
  343. code or PowerPC code. The only solution for such a problem is to 
  344. update the driver to correctly handle the interrupt issued by the card.
  345.  
  346. Other Programming Errors
  347. ========================
  348. Common programming errors may cause Type 11 or No FPU 
  349. Installed errors. These include the same kinds of errors that usually 
  350. result in address errors on 680x0-based Macintosh computers. For 
  351. example:
  352. * Indexing through an array incorrectly so that your program goes 
  353. outside the memory allocated for that array (as demonstrated above).
  354. * Disposing of memory twice
  355. * Disposing of memory that was never allocated
  356. * Calling DisposeHandle on a resource handle (use DisposeResource 
  357. instead, to ensure that the Resource Manager doesn't lose handles 
  358. behind its back.)
  359.  
  360. Some Techniques To Help Avoid Type 11 Errors
  361. ============================================
  362. The following techniques may help resolve situations that might 
  363. lead to Type 11 errors:
  364. * Test your code carefully.
  365. * Install the Debugging Modern Memory Manager, available on the 
  366. Tool chest Developer CD. This version of the Modern Memory 
  367. Manager has additional checks installed which allow you to track 
  368. down and eliminate many memory management bugs.
  369. * Use extensions such as EvenBetterBusError (found on the Tool 
  370. chest Developer CD) in conjunction with Macsbug 6.5.2 or later, to 
  371. detect use of uninitialized pointers or handles.
  372. * Use third-party testing tools such as QC¬™ by Onyx or MemoryMine¬™ 
  373. by Adianta.
  374. IMPORTANT: It goes without saying that good testing before you 
  375. release a product will prevent expensive customer support calls later 
  376. on.
  377.  
  378. User-Level Recommendations
  379. --------------------------
  380. Here are some user-level suggestions recommended by Apple for 
  381. unexplained Type 11 or No FPU installed errors:
  382. 1. Upgrade your hard disk driver(s) to the latest version available. 
  383. There are some known problems between SCSI Manager 4.3 and 
  384. some SCSI disk drivers. Starting with System 7.5, the SCSI Manager 
  385. 4.3 is installed on all Macintosh Quadras and Power Macintosh 
  386. computers. There are some known programming problems in some 
  387. older third-party disk drivers.
  388. 2. Upgrade to the latest System Software appropriate for your system. 
  389. Several significant bug fixes in system updates should reduce the 
  390. number of Type 11 and No FPU Installed errors you encounter.
  391. 3. Do a clean install of your System Software. Use the Extensions 
  392. Manager control panel to determine if any additional control panels 
  393. or extensions are conflicting with your system software.
  394. 4. Some Type 11 errors may result from corrupted PRAM. 
  395. Unfortunately, most of extended PRAM is undocumented. (See 
  396. Inside Macintosh:Operating System Utilites, chapter 7, Parameter 
  397. RAM Utilities, for what details are documented.) You can restore 
  398. your default PRAM values by holding down Command-Option-P-R 
  399. at system startup time, or by using a shareware utility such as 
  400. TechTool.
  401. 5. Make sure you are not using composite RAM in a Power 
  402. Macintosh. Memory specifications are in the developer hardware 
  403. notes for each computer.
  404. 6. Some users claim that installing the shareware extension 
  405. SoftwareFPU cuts down on No FPU Installed problems. This 
  406. extension emulates the Motorola FPU (at a considerably slower 
  407. speed), thus preventing bombs from software which incorrectly 
  408. makes FPU calls. This may alleviate no FPU Installed errors, but it 
  409. doesn't address the fundamental problem, namely that some 
  410. software is executing unexpected data or making illegal calls to a 
  411. non-existent FPU.
  412. 7. Upgrade any software you find that causes repeatable errors.
  413.  
  414. Summary
  415. =======
  416. There are no easy solutions for handling Type 11 Error or No FPU 
  417. Installed errors. Only careful debugging and testing can reduce the 
  418. number and frequency of these errors. Most problems stem from 
  419. common programming errors.
  420.  
  421. Further Reference
  422. -----------------
  423. * Inside Macintosh, PowerPC System Software, Addison-Wesley
  424. * Inside Macintosh:PowerPC Numerics, Addison-Wesley
  425. * Macsbug Reference and Debugging Guide, Addison-Wesley
  426. * Macsbug Release Notes, part of the distribution of Macsbug
  427. * Motorola MC68020 32-bit Microprocessor User's Manual, Third 
  428. edition (available from Motorola)
  429. * PowerPC Microprocessor Family: The Programming Environment 
  430. (available from IBM or Motorola)
  431. * Inside Macintosh:Memory, Addison-Wesley
  432.  
  433. This article provides information about a non-Apple product. Apple 
  434. Computer, Inc. is not responsible for its content. Please contact the 
  435. vendor for additional information.
  436. The Tech Info Library article titled "Locating Vendor Information" 
  437. can help you search for a particular vendor's address and phone 
  438. number.
  439.  
  440. This article is one of many available through the Apple Fax center. 
  441. For a complete list of available fax documents, search the Tech Info 
  442. Library for Apple Fax Document Index or call the Apple Fax line at 1-
  443. 800-505-0171 and select document number 20000 (Apple Fax - 
  444. Document Index - Product Support Literature). The Apple Fax center 
  445. is available free of charge 24 hours a day, 7 days a week.
  446.  
  447. Article Change History:
  448. 02 Jul 1996 - Added Fax Doc word
  449. 09 Apr 1996 - Removed keyword.
  450. 08 Feb 1996 - Added keyword.
  451. Copyright 1995-96, Apple Computer, Inc.
  452.  
  453. Keywords: kppc,supt,ksts,hts,ktoptil,kfax
  454. ==================================================================
  455. This information is from the Apple Technical Information Library.
  456. ArticleID: TECHINFO-0018912
  457. 19960724 15:55:27.00
  458.